<template>
  <div>
     <template>
       <div v-for="item in menuList" :key="item.id">
         <el-submenu :disabled="item.disabled" :index="item.id+''" :key="item.id+''" v-if="item.children.length>0">
           <template slot="title">
             <i :class="item.icon"></i>
             <span slot="title">{{ item.menuName }}</span>
           </template>
           <MenuTree :menuList="item.children"></MenuTree>
         </el-submenu>
         <el-menu-item
           v-else
           :disabled="item.disabled"
           :index="item.url+''"
           :router="true"
           :key="item.id"
           @click="savePath(item.url)"
           style="padding-left: 50px">
           <i :class="item.icon"></i>
           <span slot="title">{{ item.menuName }}</span>
         </el-menu-item>
       </div>

     </template>
  </div>
</template>

<script>
    export default {
        name: "MenuTree",
        props: ['menuList'],
        methods: {
            savePath(path){
                window.sessionStorage.setItem("activePath",path);
                this.activePath = path;
            }
        }
    }
</script>

<style scoped>
  .el-menu--collapse span,
  .el-menu--collapse i.el-submenu__icon-arrow {
    height: 0;
    width: 0;
    overflow: hidden;
    visibility: hidden;
    display: inline-block;
  }
</style>
